package com.hello.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hello.sky.annotation.AutoFill;
import com.hello.sky.constant.StatusConstant;
import com.hello.sky.enmu.OperationType;
import com.hello.sky.model.dto.DishDTO;
import com.hello.sky.model.entity.Dish;
import com.hello.sky.model.vo.DishOverViewVO;
import com.hello.sky.model.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜品 Mapper 接口
 * </p>
 *
 * @author D
 */
@Mapper
public interface DishMapper extends BaseMapper<Dish> {

    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);

    void delByIds(@Param("ids") List<Long> ids);

    void updateDishById(Dish dish);

    List<Dish> getDishByCategoryId(@Param("categoryId") Long categoryId);

    List<DishVO> getDishWithFlavorListByCategoryId(@Param("id") Long id, @Param("status") Integer status);

    @AutoFill(OperationType.UPDATE)
    void updateStatus(@Param("status") Integer status, @Param("id") Long id);

    @Select("select sum(status = 1) sold, sum(status = 0) discontinued from dish")
    DishOverViewVO overviewDishes();
}
